<?php
    session_start();
    if(isset($_SESSION['user'])||(isset($_SESSION['admin']))){
        header("Location: ../view/viewhome.php");
    }    
    require_once("../model/User.php");	
    $objUser = new User();	
    $objUser->set('login', filter_input(INPUT_POST, 'login'));	
    $senha=md5(filter_input(INPUT_POST,'senha'));
    $objUser->set('senha',$senha);	
    $logar=$objUser->logar();
    if($logar>0){
        session_start();
        if($logar == 3){
            $_SESSION['admin']=$objUser->login;
        }else{
            $_SESSION['user']=$objUser->login;
        }
        return false;
    }else{
	echo 'Usuário ou Senha inválidos<br>';
    }
?>
